package com.cooper.dao.admin;

import java.util.List;

import com.cooper.entity.DisplayPicConfigListDo;
import com.cooper.entity.DisplaySelectConfigListDo;
import com.cooper.pagination.PageInfo;
import com.cooper.vo.DisplayPicConfigVo;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.Insert;
import net.paoding.rose.jade.annotation.SQL;

@DAO
public interface DisplayPicConfigDAO {
	
	@Insert(tableName="d_dis_pic_config")
	Long addDisplayPicConfig(DisplayPicConfigListDo displayPicConfigListDo);
	
	@Insert(tableName="d_dis_select_config")
	Long addDisplaySelectConfig(DisplaySelectConfigListDo displaySelectConfigListDo);
	
	@SQL("select * from  d_dis_select_config where id=:1")
	DisplaySelectConfigListDo getDisplaySelectConfigList(Long id);
	
	@SQL("select * from  d_dis_select_config where outer_id=:1 and select_type=:2 and deleted='n'")
	DisplaySelectConfigListDo getDisplaySelectConfigList(Long outerId,String selectType);
	
	@SQL("select * from  d_dis_pic_config where id=:1")
	DisplayPicConfigListDo getDisplayPicConfig(Long id);
	
	@SQL("select a.id,a.title,a.dis_type,a.path,a.status,a.sort,a.comments,a.file_id from d_dis_pic_config a where a.deleted='n' "
			+ " #if(null !=:1.disType && ''!=:1.disType){ and a.dis_type=:1.disType} "
			+ " #if(null !=:1.status && ''!=:1.status){ and a.status=:1.status} "
			+ " #if(null !=:1.title && ''!=:1.title){ and a.title like CONCAT('%',:1.title,'%')} "
			+ " order by a.sort desc"
			+ " #if(null !=:2){ limit :2.startIndex,:2.pageSize} ")
	public List<DisplayPicConfigVo> queryDisplayPicConfigs(DisplayPicConfigVo queryDo, PageInfo pageInfo);
	
	@SQL("update d_dis_pic_config set modifier=:1.modifier,gmt_modified=:1.gmtModified,status=:1.status,comments=:1.comments," +
			"file_id=:1.fileId,sort=:1.sort,dis_type=:1.disType,title=:1.title,path=:1.path"
			+ " where id=:1.id")
	public void updateDisplayPicConfig(DisplayPicConfigListDo displayPicConfigListDo) throws Exception;
	
	@SQL("select count(1) from d_dis_pic_config a where a.deleted='n'  "
			+ " #if(null !=:1.disType && ''!=:1.disType){ and a.dis_type=:1.disType} "
			+ " #if(null !=:1.status && ''!=:1.status){ and a.status=:1.status} "
			+ " #if(null !=:1.title && ''!=:1.title){ and a.title like CONCAT('%',:1.title,'%')} "
			)
	int queryDisplayPicConfigCount(DisplayPicConfigVo queryDo);
	
	@SQL("update d_dis_pic_config set modifier=:1.modifier,gmt_modified=:1.gmtModified,deleted='y' where id=:1 ")
	void delete(Long id);
	
	@SQL("delete from d_dis_select_config where id=:1 ")
	void deleteSelectConfig(Long id);
}
